
import { createRouter, createWebHistory } from 'vue-router'
import RouterConfig from './config'
import nProgress from 'nprogress';
import "nprogress/nprogress.css"
const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/main',
      name: 'main',
      component: () => import('../views/MainView.vue'),
      meta: {
        path:'main',
        breadcrumbName:'首页'
     }
    },
    {
      path: '/login',
      name: 'login',
      component: () => import('../views/LoginView.vue')
      
    },
    {
      path:"/",
      redirect:"/index"
    }
  ]
})
nProgress.configure({showSpinner:false,speed:1000 })

RouterConfig.forEach(item => {
  router.addRoute("main",item)
});

router.beforeEach((to, from, next) => {
  nProgress.start();
  next()
})
router.afterEach(()=>{
  nProgress.done()
})
export default router